/*
 * Copyright (c) 2009. Silenus Consultoria, S.L.
 */
package es.silenus.detecta.service.impl;

import es.silenus.detecta.model.User;

import org.springframework.ldap.core.DirContextOperations;

import org.springframework.security.GrantedAuthority;

import java.io.Serializable;


/**
 * LDAP user mapper.
 *
 * @author <a href="mailto:malonso@silenus-consultoria.es">Mariano Alonso</a>
 * @since 26-jun-2009 14:15:54
 */
public interface LDAPUserMapper extends Serializable {
	/**
	 * Creates a fully populated User object for use by the security framework.
	 *
	 * @param ctx the context object which contains the user information.
	 * @param username the user's supplied login name.
	 * @param authorities the list of authorities which the user should be given.
	 *
	 * @return the user object.
	 */
	public User mapUserFromContext(DirContextOperations ctx, String username, GrantedAuthority[] authorities);

	/**
	 * Reverse of the above operation. Populates a context object from the supplied user object. Called when saving
	 * a user, for example.
	 *
	 * @param user the user.
	 * @param ctx the context.
	 */
	public void mapUserToContext(User user, DirContextOperations ctx);
}
